
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.FodderStorage;
import cn.edu.scau.cmi.hombio.domain.FodderType;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class FodderStorageServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected FodderStorageService service;

	/**
	 * Instantiates a new FodderStorageServiceTest.
	 *
	 */
	public FodderStorageServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Return all FodderStorage entity
	* 
	 */
	@Test
	public void findAllFodderStorages() {
		// TODO: JUnit - Populate test inputs for operation: findAllFodderStorages 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<FodderStorage> response = null;
		response = service.findAllFodderStorages(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllFodderStorages
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteFodderStorageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderStorageEmployee 
		Integer fodderstorage_id = 0;
		Integer related_employee_id = 0;
		FodderStorage response = null;
		response = service.deleteFodderStorageEmployee(fodderstorage_id, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderStorageEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveFodderStorageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderStorageEmployee 
		Integer id = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		FodderStorage response = null;
		response = service.saveFodderStorageEmployee(id, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderStorageEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderType entity
	* 
	 */
	@Test
	public void saveFodderStorageFodderType() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderStorageFodderType 
		Integer id_1 = 0;
		FodderType related_foddertype = new cn.edu.scau.cmi.hombio.domain.FodderType();
		FodderStorage response = null;
		response = service.saveFodderStorageFodderType(id_1, related_foddertype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderStorageFodderType
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findFodderStorageByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findFodderStorageByPrimaryKey 
		Integer id_2 = 0;
		FodderStorage response = null;
		response = service.findFodderStorageByPrimaryKey(id_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findFodderStorageByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderStorage entity
	* 
	 */
	@Test
	public void deleteFodderStorage() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderStorage 
		FodderStorage fodderstorage = new cn.edu.scau.cmi.hombio.domain.FodderStorage();
		service.deleteFodderStorage(fodderstorage);
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderType entity
	* 
	 */
	@Test
	public void deleteFodderStorageFodderType() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderStorageFodderType 
		Integer fodderstorage_id_1 = 0;
		Integer related_foddertype_id = 0;
		FodderStorage response = null;
		response = service.deleteFodderStorageFodderType(fodderstorage_id_1, related_foddertype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderStorageFodderType
	}

	/**
	 * Operation Unit Test
	* Return a count of all FodderStorage entity
	* 
	 */
	@Test
	public void countFodderStorages() {
		Integer response = null;
		response = service.countFodderStorages();
		// TODO: JUnit - Add assertions to test outputs of operation: countFodderStorages
	}

	/**
	 * Operation Unit Test
	* Load an existing FodderStorage entity
	* 
	 */
	@Test
	public void loadFodderStorages() {
		Set<FodderStorage> response = null;
		response = service.loadFodderStorages();
		// TODO: JUnit - Add assertions to test outputs of operation: loadFodderStorages
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderStorage entity
	* 
	 */
	@Test
	public void saveFodderStorage() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderStorage 
		FodderStorage fodderstorage_1 = new cn.edu.scau.cmi.hombio.domain.FodderStorage();
		service.saveFodderStorage(fodderstorage_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
